<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>供应商列表</title> 
<link href="${ctx}/static/css/base.css" rel="stylesheet">
<link rel="stylesheet" href="${ctx}/static/uimaker/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/static/uimaker/icon.css">
<link rel="stylesheet" href="${ctx}/static/css/providers1.css">
</head> 
<body>
    <div class="container">
       <table id="dg" style="width:100%;height:529px" title="全体供应商列表" data-options="
                rownumbers:true,
                singleSelect:false,
                autoRowHeight:false,
                pagination:true,
                fitColumns:true,
                striped:true,
                checkOnSelect:false,
                selectOnCheck:false,
                collapsible:true,
                toolbar:'#tb',
                url:'${ctx}/order/page',
                method:'get',
                pageSize:10">
            <thead>
             <tr>
				<th data-options="field:'ajOrderId',width:80">订单号</th>
				<th data-options="field:'sellerName',width:100">商家名称</th>
				<th data-options="field:'buyerName',width:80,align:'right'">车主姓名</th>
				<th data-options="field:'buyerMobile',width:80,align:'right'">车主电话</th>
				<th data-options="field:'createTime',width:140">创建时间</th>
				<th data-options="field:'price',width:60,formatter:priceFormatter">价格</th>
				<th data-options="field:'stat',width:60,align:'center'">订单状态</th>
				<th data-options="field:'id',width:60,align:'center',formatter:optFormatter">操作</th>
			</tr>
            </thead>
        </table>
      <div id="tb" style="padding:0 30px;">
        <div class="conditions">
            <span class="con-span">订单号: </span>
            <input id="orderId" class="easyui-textbox" type="text" name="orderId" style="width:166px;height:35px;line-height:35px;"></input>
            <span class="con-span">手机号: </span>
            <input id="mobile" class="easyui-textbox" type="text" name="name" style="width:166px;height:35px;line-height:35px;"></input>
            <a href="#" class="easyui-linkbutton search-btn" iconCls="icon-search" data-options="selected:true">查询</a>
            <a href="#" class="easyui-linkbutton" iconCls="icon-reload">重置</a>
            <a href="#" class="easyui-linkbutton more" iconCls="icon-more">更多</a>
        </div>
        <div class="conditions hide">
            <span class="con-span">商家: </span>
            <select id="sellerId" class="easyui-combobox" name="language" style="height:35px;width:166px;">
            	<option value="">=请选择=</option>
            	<c:forEach var="obj" items="${sellers}">
            		<option value="${obj.id}">${obj.nickname}</option>
            	</c:forEach>
            </select>
            <span class="con-span">创建时间: </span>
            <input id="beginTime" class="easyui-datebox" style="width:166px;height:35px;line-height:35px;">
            -
        	<input id="endTime" class="easyui-datebox" style="width:166px;height:35px;line-height:35px;">
        </div>
        <div class="opt-buttons">
        	<shiro:hasPermission name="order:add">
        		<a href="${ctx}/order/toadd" class="easyui-linkbutton" data-options="selected:true">新增</a>
        	</shiro:hasPermission>
        	<shiro:hasPermission name="order:excel">
	            <a href="#" class="easyui-linkbutton">导入</a>
	            <a href="#" class="easyui-linkbutton">导出</a>
        	</shiro:hasPermission>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="${ctx}/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/easyui-lang-zh_CN.js"></script>

    
    <script type="text/javascript">
    	var priceFormatter = function(a) {
    		//alert(JSON.stringify(row));
    		var num = new Number(a);
    		num = num.toFixed(2);
    		return num;
    	}
    	
    	var optFormatter = function(id, row) {
    		return '<a href="${ctx}/order/toedit/' + id + '">修改</a>' + '&nbsp;&nbsp;<a href="javascript:confirmDelete(' + id + ')">删除</a>';
    	}
    	
    	var confirmDelete = function() {
    		var id = arguments[0];
    		if (confirm("确定删除？")) {
    			//location.href = "${ctx}/order/delete/" + id;
    			var url = "${ctx}/order/delete/" + id;
    			$.getJSON(url, {}, function(data) {
    				if (data.flag == true) {
    					alert(data.message);
    					$('#dg').datagrid();
    				} else {
    					alert(data.message);
    				}
    			});
    		} 
    	}
    
    
        $(function(){
        	function doSearch(){
        		$('#dg').datagrid('load',{
        			orderId:$('#orderId').textbox('getValue'),
        			mobile:$('#mobile').textbox('getValue'),
        			sellerId:$('#sellerId').combobox('getValue'),
        			beginTime:$('#beginTime').textbox('getValue'),
        			endTime:$('#endTime').textbox('getValue')
        		});
        	}
        	
        	$('.search-btn').on('click', function() {
        		doSearch();
        	});
        	
        	$('#dg').datagrid();
        	
        	$(".more").click(function(){
                $(this).closest(".conditions").siblings().toggleClass("hide");
            });
        	
        	<c:if test="${not empty successMessage}">
        		alert('${successMessage}');
       		</c:if>
       		
       		<c:if test="${not empty errorMessage}">
    		alert('${errorMessage}');
   		</c:if>
        });    

        
    </script>
</body> 
</html>